<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>知乎日报</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link href="style/bootstrap.css" rel="stylesheet">
<link href="style/bootstrap-theme.css" rel="stylesheet">
<script src="style/jquery-2.1.1.js"></script>
<script src="style/bootstrap.js"></script>
<script src="style/own.js"></script>
<style type="text/css">
    body{  font-family: "微软雅黑";}
    div{margin: 0 auto;}
</style>

<script type="text/javascript">  
$(document).ready(function(){
	  $("a").attr("target","_blank");
	$("#more").click(function(){  
        $.ajax({  
            data:"page="+$("#page").val(),  
            type:"post",  
            dataType: 'json',  
            url:"<%= path%>/selectByLimitAjax",  
            error:function(data){  
                alert("wrong！！:"+data);  
            },  
            success:function(data){  
            		var nextpage="";
            		var datalist="";
            		var newhtml="";
            	$.each(data,function(key,values){ 
            	    $(values).each(function(){ 
            	    	if(key=='nextpage'){
            	    		nextpage=this; 
            	    		$("#page").val(nextpage);
            	    	}
            	    	if (key=='data') {
            	    		datalist=this;
            	    		newhtml+=("<a target=\"_blank\" href=<%= path%>/getBeanById/\""+datalist.id+"\">"+datalist.name+"</a><hr/>");
    					}
            	    });  
            	  });  
            $("#new").append("<br>"+newhtml);
            }
            
            }); 
    });  
    
});
</script>  

</head>
<body>
	<div class="fdiv">
		<div>
			<h2 align="center">zhihu</h2>
		</div>
		<div  style="width: 800px;">
			<c:forEach items="${list}" var="bean">
			<a href="<%= path%>/getBeanById/${bean.id }">${bean.name }</a><hr/>
			</c:forEach>
			<div id="new"></div>
		</div>
		<div align="center">
			<nav>
		  <ul class="pager">
		    <li><a href="javascript:void(0)" id="more">加载更多</a></li>
		  </ul>
		</nav>
		<a id="next" href="<%= path%>/zhihu/${4}" ></a>
			<br><br><br><br><br><br><br><br>
			<input type="hidden" value="${page+1}" id="page">
		</div>
	</div>
</body>
</html>

